# 智能语音控制系统 - Docker配置
FROM python:3.11-slim

# 设置工作目录
WORKDIR /app

# 安装系统依赖
RUN apt-get update && apt-get install -y \
    gcc \
    g++ \
    portaudio19-dev \
    python3-pyaudio \
    nodejs \
    npm \
    git \
    curl \
    && rm -rf /var/lib/apt/lists/*

# 复制Python依赖文件
COPY backend/requirements.txt .

# 安装Python依赖
RUN pip install --no-cache-dir -r requirements.txt

# 复制后端代码
COPY app.py .
COPY services/ ./services/
COPY cofig/ ./cofig/
COPY temp_audio/ ./temp_audio/
COPY asr_cache/ ./asr_cache/

# 复制前端代码
COPY font/ ./font/

# 安装前端依赖并构建
WORKDIR /app/font
RUN npm install && npm run build

# 回到工作目录
WORKDIR /app

# 暴露端口
EXPOSE 18080 3001

# 设置环境变量
ENV PYTHONUNBUFFERED=1
ENV AMAP_ENABLED=true

# 启动脚本
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["python", "app.py"]

